// pages/select-inspect-method/select-inspect-method.js
import { checkIfLogin } from '../../utils/check'
import { selfDetectInfo } from '../../services/inspect'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    spaceId:""
  },

  onShow(){
    checkIfLogin()
  },

  handleClick(){
    // console.log("自检按钮被点击了")
    // let code = '1684083551849009153'
    // wx.navigateTo({
    //   url: `/pages/inspect-charging/inspect-charging?spaceId=${code}`,
    // })
    console.log("自检按钮被点击了")

    // const _this = this
    // wx.scanCode({
    //   success (res) {
    //     let spaceId = res.result
    //     console.log("spaceId>>>", spaceId)
    //     _this.handleSelfDetectInfo(spaceId)
    //     // url = `/pages/inspect-charging/inspect-charging?spaceId=${spaceId}`
    //     // wx.navigateTo({
    //     //   url,
    //     // })
    //   }
    // })

    wx.navigateTo({
      url: `/pages/self-check-confirm/self-check-confirm`,
    })

  },

  async handleSelfDetectInfo(code){
    let res = await selfDetectInfo({code})
    if(res.code === 200){
      let url = `/pages/inspect-charging/inspect-charging?spaceId=${code}`
      wx.navigateTo({
        url,
      })
    }
  }
})